package com.springmvc.shangguigu.handlers;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

/**
 * ExceptionHandler--SpringMVC-test
 *
 * @author: Jovi
 * @createTime: 2018-09-14 16:10
 **/

@ControllerAdvice
public class SpringMvcTestExceptionHandler {

    @ExceptionHandler({ArithmeticException.class})
    public ModelAndView handlerArithmeticException(Exception e) {
        System.out.println("=====>>  出异常了：" + e);
        ModelAndView mv = new ModelAndView("shangguigu/views/error");
        mv.addObject("exception", e);
        return mv;
    }

}
